var e = getApp(), t = [ "plugin.store-alone-temp.frontend.fightGroups.list.index", "plugin.store-alone-temp.frontend.fightGroups.list.grouping", "plugin.store-alone-temp.frontend.fightGroups.list.waitPay", "plugin.store-alone-temp.frontend.fightGroups.list.waitSend", "plugin.store-alone-temp.frontend.fightGroups.list.waitReceive", "plugin.store-alone-temp.frontend.fightGroups.list.completed" ], r = "";

Page({
    data: {
        NavList: [],
        scrollTop: 0,
        selected: 0,
        isLoadMore: !0,
        orderType: "shop",
        detailUrl: "orderdetail",
        total_page: 0,
        page: 1,
        action: "",
        orderList: [],
        waitPayList: [],
        waitSendList: [],
        waitReceiveList: [],
        waitCompleteList: [],
        stopRefresh: !1,
        order_ids: [],
        isMultiplePay: !1,
        keywords: "",
        searchType: 0,
        searchTypes: [ {
            name: "商品名",
            value: 1,
            placeholder: "请输入商品名称"
        }, {
            name: "订单号",
            value: 2,
            placeholder: "请输入商品编号"
        }, {
            name: "姓名",
            value: 3,
            placeholder: "请输入收货人姓名"
        }, {
            name: "手机号",
            value: 4,
            placeholder: "请输入收货人手机号"
        } ],
        searchScreenShow: !1,
        consolidated_payment: !1,
        custom_receipt_confirmation_html: "",
        noShowTab: !1,
        debt_shop_member_type: ""
    },
    setSearchScreenShow: function() {
        this.setData({
            searchScreenShow: !this.data.searchScreenShow
        });
    },
    setSearchType: function(e) {
        var t = e.currentTarget.dataset.index;
        this.setData({
            searchType: t
        }), this.setSearchScreenShow();
    },
    onLoad: function(e) {
        var t = e.title || "我的订单";
        wx.setNavigationBarTitle({
            title: t
        }), e.orderType && "cashier" == e.orderType ? this.setData({
            orderType: "cashier",
            detailUrl: "cashierOrderdetail"
        }) : e.orderType && "stock" == e.orderType ? this.setData({
            orderType: "stock",
            detailUrl: "stockOrderdetail"
        }) : e.orderType && "store" == e.orderType ? this.setData({
            orderType: "store",
            detailUrl: "storeOrderdetail"
        }) : e.orderType && "supplier" == e.orderType ? this.setData({
            orderType: "supplier",
            detailUrl: "supplierOrderdetail"
        }) : e.orderType && "subsidiary" == e.orderType ? this.setData({
            orderType: "subsidiary",
            detailUrl: "subsidiaryOrderdetail"
        }) : e.orderType && "hotel" == e.orderType ? this.setData({
            orderType: "hotel",
            detailUrl: "HotelOrderDetail"
        }) : e.orderType && "hotel_center" == e.orderType ? this.setData({
            orderType: "hotel_center",
            detailUrl: "HotelCenterOrderDetail"
        }) : e.orderType && "hotelcashier" == e.orderType ? this.setData({
            orderType: "hotelcashier",
            detailUrl: "HotelCashierOrderDetail"
        }) : e.orderType && "lease_toy" == e.orderType ? this.setData({
            orderType: "lease_toy",
            detailUrl: "orderdetail"
        }) : e.orderType && "groups" == e.orderType ? this.setData({
            orderType: "groups",
            detailUrl: "groupDetail"
        }) : e.orderType && "auction" == e.orderType ? this.setData({
            orderType: "auction",
            detailUrl: "orderdetail"
        }) : e.orderType && "grabGroup" == e.orderType ? this.setData({
            orderType: "grabGroup",
            detailUrl: "grabGroupOrderDetail"
        }) : e.orderType && "newRetail" == e.orderType ? this.setData({
            orderType: "newRetail",
            detailUrl: "orderdetail"
        }) : e.orderType && "groupWork" == e.orderType || e.orderType && "groupWork" == e.orderType ? this.setData({
            orderType: "groupWork",
            detailUrl: "orderdetail"
        }) : e.orderType && "travelAround" == e.orderType ? this.setData({
            orderType: "travelAround",
            detailUrl: "orderdetail"
        }) : e.orderType && "sachertorte" == e.orderType ? this.setData({
            orderType: "sachertorte",
            detailUrl: "orderdetail"
        }) : e.member_type ? this.setData({
            orderType: "debt",
            detailUrl: "orderdetail",
            debt_shop_member_type: e.member_type,
            debtId: e.debtId
        }) : e.orderType || e.ordertype ? this.setData({
            orderType: e.orderType || e.ordertype,
            detailUrl: "orderdetail"
        }) : this.setData({
            orderType: "shop",
            detailUrl: "orderdetail"
        }), this.setNavList(), e.status && this.setData({
            selected: Number(e.status)
        }), this._getOrderList(this.data.selected);
    },
    setNavList: function() {
        var e = [], t = !1;
        "cashier" == this.data.orderType ? e = [ "全部", "待付款", "已完成" ] : "hotel" == this.data.orderType ? e = [ "全部", "待付款", "待确认", "待入住", "已完成", "待退房" ] : "lease_toy" == this.data.orderType ? e = [ "全部", "待支付", "待发货", "待收货", "待归还", "已完成" ] : "groups" == this.data.orderType || "ywmgroups" == this.data.orderType ? e = [ "全部", "待付款", "拼团中", "待发货", "待收货", "已完成" ] : "grabGroup" == this.data.orderType ? e = [ "抢团中", "待付款", "待发货", "待收货", "已完成" ] : "warehousePurchasing" == this.data.orderType ? e = [ "全部", "待付款", "已完成", "已关闭" ] : "stock" == this.data.orderType ? (e = [ "全部" ], 
        t = !0) : e = "ysSystem" == this.data.orderType ? [ "全部" ] : "travelAround" == this.data.orderType ? [ "全部", "待付款", "待发码", "待核销", "已核销" ] : [ "全部", "待付款", "待发货", "待收货", "已完成" ], 
        this.setData({
            NavList: e,
            noShowTab: t
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.stopRefresh ? wx.stopPullDownRefresh() : (this._initData(), this._getOrderList(this.data.selected));
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData(this.data.page, this.data.selected) : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    inpbtn: function(e) {
        var t = e.detail.value;
        this.setData({
            keywords: t
        });
    },
    inpbtnclear: function() {
        this.setData({
            keywords: ""
        });
    },
    search: function() {
        this.setData({
            selected: 0
        }), r = this.data.searchType, this._getOrderList(0);
    },
    _initData: function() {
        this.setData({
            keywords: "",
            isLoadMore: !0,
            page: 1,
            total_page: 0
        });
    },
    _getOrderList: function(r) {
        var o = new Map([ [ "cashier", [ "plugin.store-cashier.frontend.Order.list", "plugin.store-cashier.frontend.Order.list.waitPay", "plugin.store-cashier.frontend.Order.list.Completed" ] ], [ "store", [ "plugin.store-cashier.frontend.store.center.order-list.index", "plugin.store-cashier.frontend.store.center.order-list.waitPay", "plugin.store-cashier.frontend.store.center.order-list.waitSend", "plugin.store-cashier.frontend.store.center.order-list.waitReceive", "plugin.store-cashier.frontend.store.center.order-list.Completed" ] ], [ "supplier", [ "plugin.supplier.frontend.order.index", "plugin.supplier.frontend.order.wait-pay", "plugin.supplier.frontend.order.wait-send", "plugin.supplier.frontend.order.wait-receive", "plugin.supplier.frontend.order.completed" ] ], [ "hotel", [ "plugin.hotel.frontend.hotel.list", "plugin.hotel.frontend.hotel.list.wait-pay", "plugin.hotel.frontend.hotel.list.wait-send", "plugin.hotel.frontend.hotel.list.wait-enter", "plugin.hotel.frontend.hotel.list.completed" ] ], [ "hotel_center", [ "plugin.hotel.frontend.hotel.center.order-list", "plugin.hotel.frontend.hotel.center.order-list.wait-pay", "plugin.hotel.frontend.hotel.center.order-list.wait-send", "plugin.hotel.frontend.hotel.center.order-list.wait-enter", "plugin.hotel.frontend.hotel.center.order-list.completed", "plugin.hotel.frontend.hotel.center.order-list.check-out" ] ], [ "hotelcashier", [ "plugin.hotel.frontend.Order.list", "plugin.hotel.frontend.Order.list.waitPay", "plugin.hotel.frontend.Order.list.Completed" ] ], [ "lease_toy", [ "plugin.lease-toy.api.order.order-list.index", "plugin.lease-toy.api.order.order-list.wait-pay", "plugin.lease-toy.api.order.order-list.wait-send", "plugin.lease-toy.api.order.order-list.wait-receive", "plugin.lease-toy.api.order.order-list.wait-refund", "plugin.lease-toy.api.order.order-list.completed" ] ], [ "groups", [ "plugin.fight-groups.frontend.controllers.list.index", "plugin.fight-groups.frontend.controllers.list.waitPay", "plugin.fight-groups.frontend.controllers.list.grouping", "plugin.fight-groups.frontend.controllers.list.waitSend", "plugin.fight-groups.frontend.controllers.list.waitReceive", "plugin.fight-groups.frontend.controllers.list.completed" ] ], [ "ywmgroups", [ "plugin.ywm-fight-groups.frontend.controllers.list.index", "plugin.ywm-fight-groups.frontend.controllers.list.waitPay", "plugin.ywm-fight-groups.frontend.controllers.list.grouping", "plugin.ywm-fight-groups.frontend.controllers.list.waitSend", "plugin.ywm-fight-groups.frontend.controllers.list.waitReceive", "plugin.ywm-fight-groups.frontend.controllers.list.completed" ] ], [ "subsidiary", [ "plugin.subsidiary.frontend.order.index", "plugin.subsidiary.frontend.order.wait-pay", "plugin.subsidiary.frontend.order.wait-send", "plugin.subsidiary.frontend.order.wait-receive", "plugin.subsidiary.frontend.order.completed" ] ], [ "auctioneer", [ "plugin.auction.api.auctioneer-order", "plugin.auction.api.auctioneer-order.waitPay", "plugin.auction.api.auctioneer-order.waitSend", "plugin.auction.api.auctioneer-order.waitReceive", "plugin.auction.api.auctioneer-order.completed" ] ], [ "auction", [ "plugin.auction.api.auction-order", "plugin.auction.api.auction-order.waitPay", "plugin.auction.api.auction-order.waitSend", "plugin.auction.api.auction-order.waitReceive", "plugin.auction.api.auction-order.completed" ] ], [ "grabGroup", [ "plugin.snatch-regiment.api.order.grouping", "plugin.snatch-regiment.api.order.waitPay", "plugin.snatch-regiment.api.order.waitSend", "plugin.snatch-regiment.api.order.waitReceive", "plugin.snatch-regiment.api.order.completed" ] ], [ "groupWork", [ "plugin.group-work.frontend.modules.order.controllers.records.index", "plugin.group-work.frontend.modules.order.controllers.records.waitPay", "plugin.group-work.frontend.modules.order.controllers.records.waitSend", "plugin.group-work.frontend.modules.order.controllers.records.waitReceive", "plugin.group-work.frontend.modules.order.controllers.records.completed" ] ], [ "warehouseTakeDelivery", [ "plugin.warehouse.frontend.controllers.takeDelivery.order", "plugin.warehouse.frontend.controllers.takeDelivery.order.waitPay", "plugin.warehouse.frontend.controllers.takeDelivery.order.waitSend", "plugin.warehouse.frontend.controllers.takeDelivery.order.waitReceive", "plugin.warehouse.frontend.controllers.takeDelivery.order.completed" ] ], [ "warehousePurchasing", [ "plugin.warehouse.frontend.controllers.purchasing.order.index", "plugin.warehouse.frontend.controllers.purchasing.order.waitPay", "plugin.warehouse.frontend.controllers.purchasing.order.completed", "plugin.warehouse.frontend.controllers.purchasing.order.cancelled" ] ], [ "travelAround", [ "plugin.travel-around.frontend.order.list", "plugin.travel-around.frontend.order.list.waitPay", "plugin.travel-around.frontend.order.list.waitSend", "plugin.travel-around.frontend.order.list.waitReceive", "plugin.travel-around.frontend.order.list.Completed" ] ], [ "sachertorte", [ "plugin.yz-supply-cake.frontend.order.list", "plugin.yz-supply-cake.frontend.order.list.waitPay", "plugin.yz-supply-cake.frontend.order.list.waitSend", "plugin.yz-supply-cake.frontend.order.list.waitReceive", "plugin.yz-supply-cake.frontend.order.list.Completed" ] ], [ "stock", [ "plugin.order-inventory.frontend.order-list.get-inventory-list" ] ], [ "ysSystem", [ "plugin.ys-system.frontend.history-order.index" ] ], [ "newBindBox", [ "plugin.new-blind-box.frontend.list.index", "plugin.new-blind-box.frontend.list.waitPay", "plugin.new-blind-box.frontend.list.waitSend", "plugin.new-blind-box.frontend.list.waitReceive", "plugin.new-blind-box.frontend.list.Completed" ] ], [ "stockServiceInventory", [ "plugin.stock-service.frontend.controllers.stock-order.index", "plugin.stock-service.frontend.controllers.stock-order.waitPay", "plugin.stock-service.frontend.controllers.stock-order.waitSend", "plugin.stock-service.frontend.controllers.stock-order.waitReceive", "plugin.stock-service.frontend.controllers.stock-order.Completed" ] ], [ "stockServicePickUp", [ "plugin.stock-service.frontend.controllers.take-order.index", "plugin.stock-service.frontend.controllers.take-order.waitPay", "plugin.stock-service.frontend.controllers.take-order.waitSend", "plugin.stock-service.frontend.controllers.take-order.waitReceive", "plugin.stock-service.frontend.controllers.take-order.Completed" ] ] ]), a = [];
        o.has(this.data.orderType) ? (a = o.get(this.data.orderType), 1 == e.globalData.store_alone_temp && (a = t)) : a = 1 == e.globalData.store_alone_temp ? [ "plugin.store-alone-temp.frontend.order.index", "plugin.store-alone-temp.frontend.order.wait-pay", "plugin.store-alone-temp.frontend.order.wait-send", "plugin.store-alone-temp.frontend.order.wait-receive", "plugin.store-alone-temp.frontend.order.completed" ] : [ "order.list", "order.list.waitPay", "order.list.waitSend", "order.list.waitReceive", "order.list.Completed" ];
        try {
            console.log(r, a[r]), this.data.action = a[r];
        } catch (e) {
            console.log("获取请求api数据失败报错：：", e);
        }
        "newRetail" == this.data.orderType && (this.data.action = "plugin.new-retail.frontend.orderData.getList"), 
        "storeMang" == this.data.orderType && (this.data.action = "plugin.shop-assistant.frontend.order.order-list"), 
        this._getNetData(this.data.action, r);
    },
    _getNetData: function(t, o) {
        var a = this, i = e.getNetAddresss(t);
        if (i += "&page=" + this.data.page, this.data.debt_shop_member_type && (i += "&debt_shop_member_type=" + this.data.debt_shop_member_type, 
        i += "&debtor_id=" + this.data.debtId), "newRetail" == this.data.orderType) {
            var s = "";
            switch (Number(o)) {
              case 0:
                s = 5;
                break;

              case 1:
                s = 4;
                break;

              case 2:
                s = 1;
                break;

              case 3:
                s = 2;
                break;

              case 4:
                s = 3;
                break;

              default:
                s = 5;
            }
            i += "&search[keyword]=".concat(this.data.keywords || ""), i += "&search[order_status]=".concat(s);
        } else if ("storeMang" == this.data.orderType) {
            i += "&page=1", i += "&status=".concat([ "", "wait_pay", "wait_send", "wait_receive", "completed" ][o]), 
            "" != this.data.keywords && "" !== r && (i += "&search[search_type]=".concat(this.data.searchTypes[r].value), 
            i += "&search[keyword]=".concat(this.data.keywords));
        } else i += "&keyword=" + this.data.keywords;
        e._getNetWork({
            url: i,
            showToastIn: !1,
            success: function(e) {
                var t = e.data;
                if (1 == t.result) {
                    var r = t.data;
                    a.data.total_page = r.total, 0 == o ? a.setData({
                        orderList: r.data
                    }) : 1 == o ? a.setData({
                        waitPayList: r.data
                    }) : 2 == o ? a.setData({
                        waitSendList: r.data
                    }) : 3 == o ? a.setData({
                        waitReceiveList: r.data
                    }) : 4 == o ? a.setData({
                        waitCompleteList: r.data
                    }) : a.setData({
                        waitRefund: r.data
                    }), a.setData({
                        custom_receipt_confirmation_html: r.receipt_goods_notice
                    }), r.last_page <= r.current_page && a.setData({
                        isLoadMore: !1
                    });
                    try {
                        var i = wx.getStorageSync("yz_basic_info");
                        i.consolidated_payment && a.setData({
                            consolidated_payment: "1" == i.consolidated_payment
                        });
                    } catch (e) {
                        console.log(e);
                    }
                } else if (t.data.url) return wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1500,
                    success: function() {
                        setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 1500);
                    }
                }), !1;
                wx.stopPullDownRefresh();
            },
            fail: function(e) {
                wx.stopPullDownRefresh();
            }
        });
    },
    _getMoreData: function(t, o) {
        var a = this;
        if (!(this.data.page >= this.data.total_page)) {
            this.data.page = this.data.page + 1;
            var i = e.getNetAddresss(this.data.action);
            if (this.data.debt_shop_member_type && (i += "&debt_shop_member_type=" + this.data.debt_shop_member_type, 
            i += "&debtor_id=" + this.data.debtId), "newRetail" == this.data.orderType) {
                var s = "";
                switch (Number(o)) {
                  case 0:
                    s = 5;
                    break;

                  case 1:
                    s = 4;
                    break;

                  case 2:
                    s = 1;
                    break;

                  case 3:
                    s = 2;
                    break;

                  case 4:
                    s = 3;
                    break;

                  default:
                    s = 5;
                }
                i += "&search[keyword]=".concat(this.data.keywords || ""), i += "&search[order_status]=".concat(s);
            } else if ("storeMang" == this.data.orderType) {
                i += "&page=".concat(this.data.page), i += "&status=".concat([ "", "wait_pay", "wait_send", "wait_receive", "completed" ][o]), 
                "" != this.data.keywords && "" != r && (i += "&search[search_type]=".concat(this.data.searchTypes[r]), 
                i += "&search[keyword]=".concat(this.data.keywords));
            } else i += "&keyword=" + this.data.keywords;
            i += "&page=" + this.data.page, e._getNetWork({
                url: i,
                success: function(e) {
                    var t = e.data;
                    if (1 == t.result) {
                        var r = t.data;
                        t.last_page <= t.current_page && a.setData({
                            isLoadMore: !1
                        }), 0 == o ? a.setData({
                            orderList: a.data.orderList.concat(r.data)
                        }) : 1 == o ? a.setData({
                            waitPayList: a.data.waitPayList.concat(r.data)
                        }) : 2 == o ? a.setData({
                            waitSendList: a.data.waitSendList.concat(r.data)
                        }) : 3 == o ? a.setData({
                            waitReceiveList: a.data.waitReceiveList.concat(r.data)
                        }) : 4 == o ? a.setData({
                            waitCompleteList: a.data.waitCompleteList.concat(r.data)
                        }) : a.setData({
                            waitRefund: a.waitRefund.concat(r.data)
                        });
                    }
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        }
    },
    swichTabTItem: function(e) {
        var t = e.detail.index;
        this.setData({
            selected: t
        }), this._initData(), this._getOrderList(this.data.selected);
    },
    onPageScroll: function(e) {
        this.setData({
            scrollTop: e.scrollTop
        });
    },
    stopRefresh: function(e) {
        var t = e.detail;
        this.setData({
            stopRefresh: t
        });
    },
    multiplePayAction: function(e) {
        var t = e.detail;
        this.setData({
            order_ids: t
        }), t.length > 0 ? this.setData({
            isMultiplePay: !0
        }) : this.setData({
            isMultiplePay: !1
        });
    },
    toMultiplePay: function() {
        wx.navigateTo({
            url: "/packageD/buy/orderPay/orderPay?order_id=" + this.data.order_ids.join(",") + "&status=2"
        });
    },
    cofirmOrderAction: function(e) {
        var t = e.detail;
        if (0 == this.data.selected) this._getOrderList(this.data.selected); else if ("pay" == t) this._getOrderList(this.data.selected); else {
            for (var r = this.data.waitReceiveList, o = 0; o < r.length; o++) t == r[o].id && r.splice(o, 1);
            this.setData({
                waitReceiveList: r
            });
        }
    },
    goNewBindBoxPage: function() {
        wx.navigateTo({
            url: "/packageF/new_blind_box/index"
        });
    }
});